﻿#include "UdpCodec_HeartBeat.h"

#include "RegisterCenter_Device.h"
#include "Mapper_Test_RTT.h"

#include <qdatetime.h>

UdpCodec_HeartBeat::UdpCodec_HeartBeat()
{
  setObjectName(getClassNameFirstLow<UdpCodec_HeartBeat>());
}

UdpCodec_HeartBeat::~UdpCodec_HeartBeat()
{

}

DataPackage_UdpCodec* UdpCodec_HeartBeat::decode(DataPackage_UdpCodec* dataPackageInfo_Device)
{
  registerCenter_Device->updateLifeTime(dataPackageInfo_Device->getDeviceId(),
                                        dataPackageInfo_Device->getMsgId(),
                                        dataPackageInfo_Device->getSenderAddress(),
                                        dataPackageInfo_Device->getSenderPort());
//  return dataPackageInfo_Device->toAck();
  return Q_NULLPTR;
}

RegisterCenter_Device* UdpCodec_HeartBeat::getRegisterCenter_Device()const
{
  return registerCenter_Device;
}

UdpCodec_HeartBeat* UdpCodec_HeartBeat::setRegisterCenter_Device(RegisterCenter_Device* const registerCenter_Device)
{
  this->registerCenter_Device=registerCenter_Device;
  return this;
}

Mapper_Test_RTT* UdpCodec_HeartBeat::getMapper_Test_RTT() const
{
  return mapper_Test_RTT;
}

UdpCodec_HeartBeat* UdpCodec_HeartBeat::setMapper_Test_RTT(Mapper_Test_RTT* const mapper_Test_RTT)
{
  this->mapper_Test_RTT=mapper_Test_RTT;
  printInjection(this,mapper_Test_RTT);
  return this;
}

void UdpCodec_HeartBeat::objectAutoInjection(QHash<QString, QObject *> *objMap)
{
  setRegisterCenter_Device(getObjFromMap<RegisterCenter_Device>(objMap));
  setMapper_Test_RTT(getObjFromMap<Mapper_Test_RTT>(objMap));
}
